package com.huohuzhihui.controller;

import com.huohuzhihui.model.AccountVo;
import com.huohuzhihui.model.bo.AssetSetInputBO;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.transaction.model.dto.TransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;

@RestController
public class FiscoController {


    @RequestMapping("/account")
    public AccountVo account(){
        // 创建非国密类型的CryptoSuite
        CryptoSuite cryptoSuite = new CryptoSuite(CryptoType.ECDSA_TYPE);
        // 随机生成非国密公私钥对
        CryptoKeyPair cryptoKeyPair = cryptoSuite.createKeyPair();
        // 获取账户地址
        String primaryKey = cryptoKeyPair.getHexPrivateKey();
        String publicKey = cryptoKeyPair.getHexPublicKey();
        String accountAddress = cryptoKeyPair.getAddress();

        AccountVo accountVo = new AccountVo();
        accountVo.setPrimaryKey(primaryKey);
        accountVo.setPublicKey(publicKey);
        accountVo.setAccountAddress(accountAddress);
        return  accountVo;
    }
}
